.image-tool {
    @bg-color: #cdd1e0;
    @front-color: #388ae5;
    @border-color: #e8e8eb;

    &__image {
        border-radius: 3px;
        margin-bottom: 10px;
        position: relative;
        text-align: center;
        display: inline-block;

        &-picture {
            border-radius: 6px;
            max-width: 100%;
            vertical-align: bottom;
            // display: block;
        }

        &-preloader {
            width: 50px;
            height: 50px;
            border-radius: 50%;
            background-size: cover;
            margin: auto;
            position: relative;
            background-color: @bg-color;
            background-position: center center;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);

            &:after {
                content: "";
                position: absolute;
                z-index: 3;
                width: 60px;
                height: 60px;
                border-radius: 50%;
                border: 2px solid @bg-color;
                border-top-color: @front-color;
                left: 50%;
                top: 50%;
                margin-top: -30px;
                margin-left: -30px;
                animation: image-preloader-spin 2s infinite linear;
                box-sizing: border-box;
            }
        }
    }

    &__caption {
        display: none;

        &[contentEditable="true"][data-placeholder]::before {
            position: absolute !important;
            content: attr(data-placeholder);
            color: #707684;
            font-weight: normal;
            display: none;
        }

        &[contentEditable="true"][data-placeholder]:empty {
            &::before {
                display: block;
            }

            &:focus::before {
                display: none;
            }
        }
    }

    &--empty {
        .image-tool__image {
            overflow: hidden;
        }
    }

    &--empty,
    &--uploading {
        &__caption {
            display: none !important;
        }
    }

    &--uploading {
        .image-tool__image {
            overflow: hidden;
        }

        &__image {
            min-height: 200px;
            display: flex;
            border: 1px solid @border-color;
            background-color: #fff;
            overflow: hidden;

            &-picture {
                display: none;
            }
        }

        .cdx-button {
            display: none;
        }
    }

    .cdx-button {
        display: flex;
        align-items: center;
        justify-content: center;

        svg {
            height: auto;
            margin: 0 6px 0 0;
        }
    }

    &--filled {
        .cdx-button {
            display: none;
        }

        .image-tool__image {
            &-preloader {
                display: none;
            }
        }
    }

    &--withBorder {
        .image-tool__image {
            border: 1px solid @border-color;
            box-sizing: border-box;
        }
    }

    &--withBackground {
        .image-tool__image {
            padding: 15px;
            box-sizing: border-box;
            background: @bg-color;

            &-picture {
                max-width: 60%;
                margin: 0 auto;
            }
        }
    }

    &--stretched {
        .image-tool__image {
            &-picture {
                width: 100%;
            }
        }
    }

    &--alignLeft {
        text-align: left;
    }

    &--alignCenter {
        text-align: center;
    }

    &--alignRight {
        text-align: right;
    }

    &--caption {
        .image-tool__caption {
            display: block;
        }
    }
}

@keyframes image-preloader-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.image-tool__wrapper {
    position: relative;
    box-sizing: border-box;
}

.image-tool__resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background-color: #3d3d3d;
    user-select: none;
    z-index: 1000;
    display: none;
    border: 2px solid #fff;
    box-sizing: border-box;
}

.image-tool__resize-handle--top {
    top: -6px;
    left: calc(50% - 6px);
    cursor: n-resize;
}

.image-tool__resize-handle--bottom {
    bottom: -6px;
    left: calc(50% - 6px);
    cursor: s-resize;
}

.image-tool__resize-handle--left {
    top: calc(50% - 6px);
    left: -6px;
    cursor: w-resize;
}

.image-tool__resize-handle--right {
    top: calc(50% - 6px);
    right: -6px;
    cursor: e-resize;
}

.image-tool__resize-handle--top-left {
    left: -6px;
    top: -6px;
    cursor: nw-resize;
}

.image-tool__resize-handle--top-right {
    right: -6px;
    top: -6px;
    cursor: ne-resize;
}

.image-tool__resize-handle--bottom-left {
    left: -6px;
    bottom: -6px;
    cursor: sw-resize;
}

.image-tool__resize-handle--bottom-right {
    right: -6px;
    bottom: -6px;
    cursor: se-resize;
}